﻿using System;
using System.Linq;
using MongoDB.Bson;
using MongoDB.Driver;
using System.Data.SQLite;
using Newtonsoft.Json;
using MongoDB.Bson.Serialization;
using SupermarketModel;
using Supermarket.Data;
using System.Data.Entity;

namespace SupermarketTestFill
{
    public class ProductsTotalReport
    {
        public static void GenerateExcelReport()
        {
            var sqLiteDb = new SQLiteConnection("SqLiteDb");
            FillUpSqLite(sqLiteDb);
        }

        private static void FillUpSqLite(SQLiteConnection conn)
        {
            using (conn)
            {
                var data = MongoDbProvider.db.LoadData<BsonDocument>().ToList();

                foreach (var item in data)
                {
                    var sqLiteObject = new JsonObject();
                    sqLiteObject.productId = item[1].ToInt32();
                    sqLiteObject.productName = item[2].ToString();
                    sqLiteObject.vendorName = item[3].ToString();
                    sqLiteObject.totalQuantitySold = item[4].ToInt32();
                    sqLiteObject.totalIncomes = (decimal)item[5].ToDouble();
                }

            }
        }
    }
}
